home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / std / c++ / 1040 < prev    next >
Encoding:
Internet Message Format  |  1996-08-06  |  2.0 KB

  1. From: Rich Paul <rpaul@trcinc.com>
  2. Message-ID: <316D4ABB.1C7A@trcinc.com>
  3. X-Original-Date: Thu, 11 Apr 1996 14:08:59 -0400
  4. Path: in2.uu.net!bounce-back
  5. Date: 12 Apr 96 07:30:59 GMT
  6. Approved: fjh@cs.mu.oz.au
  7. Newsgroups: comp.std.c++
  8. Subject: Re: Template Syntax
  9. Organization: Technical Resource Connection
  10. References: <199604102351.QAA11178@netcom15.netcom.com>
  11. X-Mailer: Mozilla 2.01Gold (WinNT; I)
  12. X-Auth: PGPMoose V1.1 PGP comp.std.c++
  13.     iQBFAgUBMW4G2+EDnX0m9pzZAQFrFgF/dBP/r0wnAB4JEQksKwBkhDlY62+mD7cW
  14.     vwr/WYli+srAWp2OH9lFvc+CbHE9It2Q
  15.     =6exD
  16.  
  17. > the declaration of operator= was legal, because the use of the token
  18. > "Array" as a return type and a paramter was implicitly treated as if it
  19. > were "Array<T>." Many compilers accept this, but I'm told that several
  20. > reject it, and I can't find language in the January DWP that allows it.
  21.  
  22. As I implemented the standard string class, I learned that one 
  23. of my compilers accepts this, while another rejects it.  
  24. MSVC4.0 and Borland 5, respectively.  I'd suspect that it a 
  25. recently removed language feature, but for portability, I used 
  26. this:
  27.  
  28. template < class charT, class traits, class Allocator >
  29. class basic_string 
  30. {
  31.     typedef basic_string<charT, traits, Allocator> self;
  32.  
  33.     public:
  34.     basic_string ( const self & );
  35. };
  36.  
  37. The only problem I haven't worked around is that I'd like to 
  38. say:
  39.  
  40. template<class charT, class traits, class Allocator >
  41. self operator + ( const self &lhs, const self &rhs )
  42. {
  43.     return self ( lhs )+= rhs;
  44. };
  45.  
  46. Alas, since there is no scope in which to use the typedef, I'm 
  47. stuck with spelling it out ...
  48.  
  49. Regards,
  50. Rich
  51.  
  52. (BTW, are you Scott Meyers of More Effective C++ fame?  If so, 
  53. great job!)
  54. ---
  55. [ comp.std.c++ is moderated.  To submit articles: try just posting with      ]
  56. [ your news-reader.  If that fails, use mailto:std-c++@ncar.ucar.edu         ]
  57. [ FAQ:      http://reality.sgi.com/employees/austern_mti/std-c++/faq.html    ]
  58. [ Policy:   http://reality.sgi.com/employees/austern_mti/std-c++/policy.html ]
  59. [ Comments? mailto:std-c++-request@ncar.ucar.edu                             ]
  60.